//
//  ThreeDataViewCell.m
//  MISCloud
//
//  Created by goldeney on 13-8-29.
//  Copyright (c) 2013年 goldeneye. All rights reserved.
//

#import "ThreeDataViewCell.h"
#import <QuartzCore/QuartzCore.h>

@implementation ThreeDataViewCell

@synthesize iconButton;
@synthesize titleLabel;
@synthesize checkButton;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
		
		iconButton = [UIButton buttonWithType:UIButtonTypeCustom];
		[iconButton setFrame:CGRectMake(10, 4, 30, 36)];
		[iconButton setAdjustsImageWhenHighlighted:NO];
        [iconButton setUserInteractionEnabled:NO];
        iconButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
		//[iconButton addTarget:self action:@selector(iconButtonAction:) forControlEvents:UIControlEventTouchUpInside];
		[iconButton setImage:[UIImage imageNamed:@"Close.png"] forState:UIControlStateNormal];
		[iconButton setImage:[UIImage imageNamed:@"Open.png"] forState:UIControlStateSelected];
		[self.contentView addSubview:iconButton];
		
		titleLabel = [[UILabel alloc] init];
		[titleLabel setFont:[UIFont systemFontOfSize:17.0]];
		[titleLabel setTextColor:[UIColor blackColor]];
		[titleLabel setUserInteractionEnabled:NO];
		[titleLabel setFrame:CGRectMake(47, 7, 216, 24)];
		[self.contentView addSubview:titleLabel];
        
        checkButton = [[SSCheckBoxView alloc] initWithFrame:CGRectMake(274, 3, 46, 40)
                                                      style:kSSCheckBoxViewStyleGrayGreen checked:NO];
        [checkButton setUserInteractionEnabled:YES];
        [self.contentView addSubview:checkButton];
		
		[self.accessoryView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleBottomMargin];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setIndentationLevel:(NSInteger)level
{
    CGRect rect;
    
    rect = iconButton.frame;
    rect.origin.x = 10 + 15 * level;
    iconButton.frame = rect;
    
    rect = titleLabel.frame;
    rect.origin.x = 47 + 15 * level;
    rect.size.width = 226 - 15 * level;
    titleLabel.frame = rect;
}

@end
